package com.ibeetl.admin.core.util;

import com.ibeetl.admin.core.entity.CoreUser;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class SessionListener implements HttpSessionListener {
    /**
     登入用户
     */
    public static Map<Long, String> LOGIN_USER_MAP = new HashMap<Long, String>();
    /**
     逼下线用户
     */
    public static Map<String, Long> LOGOUT_USER_MAP = new HashMap<>();

    public static final String LOGGIN_SESSION_ID = "LOGINUSER_XXXYYY";

    /**
     session创建
     */

    @Override
    public void sessionCreated(HttpSessionEvent event) {
    }

    /**
     session销毁
     */

    @Override
    public void sessionDestroyed(HttpSessionEvent event) {
        HttpSession session = event.getSession();
        String sessionId = session.getId();
        SessionListener.LOGOUT_USER_MAP.remove(sessionId);
    }
}